{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "package main\n",
    "\n",
    "import (\n",
    "\t\"fmt\"\n",
    ")\n",
    "\n",
    "func loopSlice(list []int) {\n",
    "\tfor _, v := range list {\n",
    "\t\tfmt.Print(v, \" \")\n",
    "\t}\n",
    "\tfmt.Print(\"\\n\")\n",
    "}\n",
    "\n",
    "func loopArray(list [4]int) {\n",
    "\tfor _, v := range list {\n",
    "\t\tfmt.Print(v, \" \")\n",
    "\t}\n",
    "\tfmt.Print(\"\\n\")\n",
    "}\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2 3 4 \n",
      "1 2 3 4 \n"
     ]
    }
   ],
   "source": [
    "a := []int{2, 3, 4}\n",
    "b := [4]int{1, 2, 3, 4}\n",
    "\n",
    "loopSlice(a)\n",
    "loopArray(b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "ename": "ERROR",
     "evalue": "repl.go:1:11: cannot use <[]int> as <[4]int> in argument to loopArray",
     "output_type": "error",
     "traceback": [
      "repl.go:1:11: cannot use <[]int> as <[4]int> in argument to loopArray"
     ]
    }
   ],
   "source": [
    "loopArray(a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "ename": "ERROR",
     "evalue": "repl.go:1:11: cannot use <[4]int> as <[]int> in argument to loopSlice",
     "output_type": "error",
     "traceback": [
      "repl.go:1:11: cannot use <[4]int> as <[]int> in argument to loopSlice"
     ]
    }
   ],
   "source": [
    "loopSlice(b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "So the `array` in golang is length fixed. If you want to use it. You have to clearly specify the length of that array. \n",
    "\n",
    "\n",
    "Meanwhile, the `slice` is different, you don't have to specify the length of it."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Again:\n",
    "* array: `var a [5]int`\n",
    "* slice: `var b []int`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Go",
   "language": "go",
   "name": "gophernotes"
  },
  "language_info": {
   "codemirror_mode": "",
   "file_extension": ".go",
   "mimetype": "",
   "name": "go",
   "nbconvert_exporter": "",
   "pygments_lexer": "",
   "version": "go1.15.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
